package com.yealove.lunchparty.listener;

import org.directwebremoting.ScriptSession;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.directwebremoting.event.ScriptSessionEvent;
import org.directwebremoting.event.ScriptSessionListener;

import java.util.HashMap;
import java.util.Map;

public class AddScriptSessionListener implements ScriptSessionListener {
    public static Map<String, ScriptSession> sc = new HashMap<String, ScriptSession>();

    public void sessionCreated(ScriptSessionEvent ev) {
        WebContext webContext = WebContextFactory.get();
        sc.put(webContext.getSession().getId(), ev.getSession());
        System.out.println("add --------->" + ev.getSession().getId());

    }

    public void sessionDestroyed(ScriptSessionEvent ev) {
        System.out.println("remove --------->" + ev.getSession().getId());
    }

}  